package com.hjt.gulimall.search.controller;

import com.hjt.common.to.es.SkuEsModel;
import com.hjt.common.utils.R;
import com.hjt.gulimall.search.service.ProductSaveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author:97007
 * @date:2021/9/19 23:37
 */
@RestController
@RequestMapping("/search/save")
public class ElasticSaveController {

    @Autowired
    ProductSaveService productSaveService;

    // 上架商品
    @PostMapping("/product")
    public R productStatusUp(@RequestBody List<SkuEsModel> skuEsModelList) {
        boolean flag = productSaveService.productStatusUp(skuEsModelList);
        if (flag) {
            return R.ok();
        } else {
            return R.error("商品上架失败");
        }
    }
}
